﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;
namespace LogicUniversity
{
    public partial class RetrievalList : System.Web.UI.Page
    {
        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //(Session["Role"]
            if (Session["Role"] as string != "Clerk")
            {
                Response.Redirect("~/Login.aspx");
            }

        }

        CompositeReterivalData passData = new CompositeReterivalData();

        public CompositeReterivalData PassData
        {
            get { return (CompositeReterivalData)this.ViewState["passData"]; }
            set { this.ViewState["passData"] = value; }
        }
        RetrievalListController retController = new RetrievalListController();
        List<CompositeReterivalData> result;
        protected void Page_Load(object sender, EventArgs e)
        {
            result = retController.getCompositeReterivalData();

            if (result == null || result.Count <= 0)
            {
                lblMsg.Text = "Currently No Retrieval Lists.";
            }
            else
            {
                grdCompositeRetrievalList.DataSource = result;
                grdCompositeRetrievalList.DataBind();
            }
        }

        protected void grdCompositeRetrievalList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ViewDetail")
            {
                CompositeReterivalData comReterData = new CompositeReterivalData();
                int row = Convert.ToInt32(e.CommandArgument);
                comReterData.Item_Code = grdCompositeRetrievalList.Rows[row].Cells[0].Text;
                comReterData.Item_Description = grdCompositeRetrievalList.Rows[row].Cells[1].Text;
                comReterData.RequestedQty = Convert.ToInt16(grdCompositeRetrievalList.Rows[row].Cells[2].Text);
                comReterData.RetrievedQty = Convert.ToInt16(grdCompositeRetrievalList.Rows[row].Cells[3].Text);
                comReterData.Batch_No = result[0].Batch_No;
                this.ViewState["passData"] = comReterData;
                Server.Transfer("RetrivalList_Detail.aspx");
            }
        }
    }
}